import { LJPuppeteer, LaunchOpt } from "../api/LJPuppeteer";
import { PuppeteerButton } from "../api/PuppeteerButton";
import { PuppeteerInput } from "../api/PuppeteerInput";
import { PuppeteerBase } from "../api/PuppeteerBase";

export class PuppeteerServer {
    Puppeteer: LJPuppeteer;
    Button: PuppeteerButton;
    Input: PuppeteerInput;
    constructor() {
        this.Puppeteer = new LJPuppeteer();
    }
    async createPage(Url: string, Opt?: LaunchOpt) {
        await this.Puppeteer.createPage(Url,Opt)
        this.Button = this.Puppeteer.createButton();
        this.Input = this.Puppeteer.createInput();
        return true;
    }
    //判断是否有初始化Page
    isPageUndefined() {
        if (LJPuppeteer.Page == undefined) {
            throw Error('请调用createPage方法初始化Page!')
        }
    }
}


(async function () {
    let p = new PuppeteerServer();
    await p.createPage("http://www.baidu.com")
    await p.Input.typeValue('#kw', "hello");
    // await p.Puppeteer.closeBrowser();s
})()
